package com.example.myapplication;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class GamerAdapter extends ArrayAdapter<Gamer> {

    public GamerAdapter(@NonNull Context context, int resource, @NonNull List<Gamer> objects)
    {
        super(context,resource,objects);
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        Gamer gamer = getItem(position);

        View view = LayoutInflater.from(getContext()).inflate(R.layout.game_item,parent,false);
        ImageView gameimage = view.findViewById(R.id.game_image);
        TextView gamename = view.findViewById(R.id.game_name);

        gameimage.setImageResource(gamer.getImageID());
       gamename.setText(gamer.getName());
        return view;
    }
}
